package com.easyCode.sqlMapper.renderHandler;

import com.easyCode.sqlMapper.mapInfo.TableMapInfo;
import com.easyCode.sqlMapper.template.RenderHandler;
import com.easyCode.sqlMapper.template.SqlTemplateConfig;
import com.easyCode.sqlMapper.template.TemplateContext;
import org.apache.velocity.VelocityContext;

/**
 * dao层渲染参数准备
 *
 * @author 大忽悠
 * @create 2022/12/3 17:45
 */
public class MapperRenderHandler implements RenderHandler<VelocityContext> {

    @Override
    public String paramPrepare(VelocityContext velocityContext, TableMapInfo tableMapInfo, SqlTemplateConfig sqlTemplateConfig, TemplateContext templateContext) {
        velocityContext.put("packagePath", sqlTemplateConfig.getMapperModuleName());
        velocityContext.put("className",tableMapInfo.getTableName());
        velocityContext.put("daoModule",sqlTemplateConfig.getDaoModuleName());

        templateContext.setVal(TemplateContext.JAVA_FILE_NAME,tableMapInfo.getTableName()+"Mapper.java");

        return sqlTemplateConfig.getMapperModuleName();
    }
}
